package com.wxy.demo;

/**
 * @author wangxiaoyuan
 * 2021/3/29 9:54
 **/

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.util.ArrayList;
import java.util.List;

/**
 * 服务实现类
 */
@WebService(endpointInterface = "com.wxy.demo.MyService",
        name = "Login",// 定义Port名称
        serviceName = "MyService", // 修改WebService服务名称
        targetNamespace = "http://com.wxy.demo/" // 定义命名空间，默认为倒置的包名
//服务实现类和接口的注解要一样全
)
public class MyServiceImpl implements MyService {

    @WebMethod(operationName = "authorization" // 修改方法名
    )
    @Override
    public String authorization(
            @WebParam(name = "userId") String userId,
            @WebParam(name = "password") String password) {
        if ("admin".equals(userId) && "123456".equals(password)) {
            return "success";
        }
        return "error";
    }

    @WebMethod(operationName = "getAll")
    @Override
    public List<User> getAll() {
        ArrayList<User> list = new ArrayList<>();
        list.add(new User(1, "zhangsan", 18, "男"));
        list.add(new User(2, "lisi", 20, "女"));
        list.add(new User(3, "wangwu", 12, "女"));
        list.add(new User(4, "zhaoliu", 28, "男"));
        return list;
    }

    @WebMethod(operationName = "getAssetsList")
    @Override
    public List<Assets> getAssetsList() {
        ArrayList<Assets> list = new ArrayList<>();
        list.add(new Assets("123","123","123","123","123"));
        list.add(new Assets("123","123","123","123","123"));
        list.add(new Assets("123","123","123","123","123"));
        list.add(new Assets("123","123","123","123","123"));
        return list;
    }

}